#!/bin/bash
# chkconfig: 2345 10 90
beat_path="/usr/local/filebeat/"
cd ${beat_path}
start() {
    ./filebeat -c config/filebeat.yml > /dev/null 2>&1 &
    sleep 2
    echo -e "start filebeat success"
}

stop() {
    beat_pid=$(ps aux|grep filebeat|grep -v grep|grep config|awk '{print $2}')
    kill -9 ${beat}
    sleep 2
    echo -e "stop filebeat success"
}

case $1 in
    start)
        start;;
    stop)
        stop;;
    restart)
        stop
        start;;
    *)
        echo "Usage start|stop|restart"
esac
